package com.example.ykbboom.universitytransportation.Util;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.amap.api.maps.AMap;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.example.ykbboom.universitytransportation.Activity.LoginActivity;
import com.example.ykbboom.universitytransportation.Activity.MainActivity;
import com.example.ykbboom.universitytransportation.Activity.MyRequestActivity;
import com.example.ykbboom.universitytransportation.Activity.RequestDetailActivity;
import com.example.ykbboom.universitytransportation.MyApplication;
import com.example.ykbboom.universitytransportation.NetModel.MyGsonRequest;
import com.example.ykbboom.universitytransportation.NetModel.NetAccessUrl;
import com.example.ykbboom.universitytransportation.POJO.MyRequestDetailItem;
import com.example.ykbboom.universitytransportation.VO.AroundSearchInfoVO;
import com.example.ykbboom.universitytransportation.VO.AroundSearchVO;
import com.example.ykbboom.universitytransportation.VO.BaseResultVO;
import com.example.ykbboom.universitytransportation.VO.LoginResultVO;
import com.example.ykbboom.universitytransportation.VO.MyUserRequestItemVO;
import com.example.ykbboom.universitytransportation.VO.OrderItemVO;
import com.example.ykbboom.universitytransportation.VO.UserAllOrderVO;
import com.example.ykbboom.universitytransportation.VO.UserAllRequestVO;
import com.example.ykbboom.universitytransportation.VO.UserRequestDetailVO;
import com.example.ykbboom.universitytransportation.VO.UserVO;
import com.example.ykbboom.universitytransportation.View.MyRequestDetailAdapter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ykbboom on 2017/3/3 15:17
 * email：ykbpro@whut.edu.cn
 */

public class NetUtil {
    private static final String TAG = "NetUtil";
    private static RequestQueue requestQueue = MyApplication.getRequestQueue();
    private static Context context = MyApplication.getContext();

    public static void RegAndLogin(final UserVO userVO, final Activity activity){
        Map<String,String> params=new HashMap<String, String>();
        params.put("userPhone",userVO.getUserPhone());
        params.put("userPass", userVO.getUserPass());
        params.put("userName", userVO.getUserName());
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.REG,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
            @Override
            public void onResponse(BaseResultVO baseResultVO) {
                LogUtil.i(TAG,"回调RegAndLogin onResponse()方法");
                if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                    ToastUtil.showToast(context,baseResultVO.getMsg());
                }else {
                    //调用缓存将信息缓存下来
                    LogUtil.i(TAG,"Reg缓存信息");
                    SharedPrefUtil.saveUserName(userVO.getUserName());
                    SharedPrefUtil.saveUserPhone(userVO.getUserPhone());
                    SharedPrefUtil.saveLoginState(true);
                    SharedPrefUtil.saveDriverState(false);//默认是游客状态
                    SharedPrefUtil.saveCheckDistance(3000);//默认检索距离3000m

                    Intent intent = new Intent(activity, MainActivity.class);
                    activity.startActivity(intent);
                    activity.finish();
                }
            }
        },
                new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                LogUtil.e(TAG,volleyError.toString());
            }
        });
        requestQueue.add(myGsonRequest);
    }

    public static void updatePassword(String userPhone,String newPass, final Activity activity){
        Map<String,String> params=new HashMap<String, String>();
        params.put("userPhone",userPhone);
        params.put("newPass", newPass);
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.UPDATE_USER_PASSWORD,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }else {
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                            Intent intent = new Intent(activity, LoginActivity.class);
                            activity.startActivity(intent);
                            activity.finish();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }

    public static void Login(final String userPhone, String userPass, final Activity activity,final ProgressDialog dialog){
        LogUtil.i(TAG,"phone:"+userPhone);
        LogUtil.i(TAG,"password:"+userPass);

        Map<String,String> params=new HashMap<String, String>();
        params.put("userPhone",userPhone);
        params.put("userPass",userPass);
        MyGsonRequest<LoginResultVO>myGsonRequest = new MyGsonRequest<LoginResultVO>(
                Request.Method.POST,
                NetAccessUrl.LOGIN,
                params,
                LoginResultVO.class,
                new Response.Listener<LoginResultVO>() {
                    @Override
                    public void onResponse(LoginResultVO loginResultVO) {
                        LogUtil.i(TAG,"回调Login onResponse()方法");
                        if (loginResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,loginResultVO.getMsg());
                            dialog.dismiss();
                        }else {
                            LogUtil.i(TAG,"Login缓存信息,服务端积分为"+loginResultVO.getUserPoint());
                            SharedPrefUtil.saveLoginState(true);
                            SharedPrefUtil.saveDriverState(false);//默认是游客状态
                            SharedPrefUtil.saveUserPhone(userPhone);
                            SharedPrefUtil.saveUserName(loginResultVO.getUserName());
                            SharedPrefUtil.saveCheckDistance(3000);//默认检索距离3000m

                            dialog.dismiss();
                            Intent intent = new Intent(activity, MainActivity.class);
                            activity.startActivity(intent);
                            activity.finish();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }

    /**
     * 发布请求
     * */
    public static void publishReq(String picUrl,String desc,String place,String destination,String time,
                                  String userPhone,String latlongStart,String latlongDes,final Activity activity){
        LogUtil.i(TAG,"picUrl:"+picUrl);

        Map<String,String> params=new HashMap<String, String>();
        params.put("picurl",picUrl);
        params.put("description",desc);
        params.put("place",place);
        params.put("destination",destination);
        params.put("time",time);
        params.put("userPhone",userPhone);
        params.put("latlongStart",latlongStart);
        params.put("latlongDes",latlongDes);
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.PUBLISH_REQUEST,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        LogUtil.i(TAG,"回调publishReq onResponse()方法");
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,baseResultVO.getErrorResult().getErrorMsg());
                        }else {
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                            Intent intent = new Intent(activity, MainActivity.class);
                            activity.startActivity(intent);
                            activity.finish();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                        ToastUtil.showToast(context,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 检索周围请求
     * */
    public static void aroundSearch(String userPhone,String center, String radius, final AMap aMap){
        Map<String,String> params=new HashMap<>();
        params.put("center",center);
        params.put("radius",radius);
        params.put("userPhone",userPhone);
        MyGsonRequest<AroundSearchVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.AROUND_SEARCH,
                params,
                AroundSearchVO.class,
                new Response.Listener<AroundSearchVO>() {
                    @Override
                    public void onResponse(AroundSearchVO aroundSearchVO) {
                        LogUtil.i(TAG,"aroundSearch onResponse()方法");
                        if (aroundSearchVO.getResultCode()==AroundSearchVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,aroundSearchVO.getMsg());
                        }else {
                            for (AroundSearchInfoVO aroundSearchInfoVO:aroundSearchVO.getAroundSearchInfoVOS()){
                                MarkerOptions markerOptions = new MarkerOptions().icon(BitmapDescriptorFactory
                                        .defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
                                        .position(new LatLng(aroundSearchInfoVO.getLatitude(),aroundSearchInfoVO.getLongitude()))
                                        .title("请求号:"+aroundSearchInfoVO.get_id())
                                        .snippet("起点:"+aroundSearchInfoVO.getPlace()+"\n终点:"+aroundSearchInfoVO.getDestination())
                                        .draggable(false);
                                aMap.addMarker(markerOptions);
                            }
                            ToastUtil.showToast(context,aroundSearchVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 获取请求详细信息
     * */
    public static void getRequestDetail(final String gdIdStart, final Activity activity){
        Map<String,String> params=new HashMap<String, String>();
        params.put("gdIdStart",gdIdStart);
        MyGsonRequest<UserRequestDetailVO>myGsonRequest = new MyGsonRequest<UserRequestDetailVO>(
                Request.Method.POST,
                NetAccessUrl.GET_REQUEST_DETAIL,
                params,
                UserRequestDetailVO.class,
                new Response.Listener<UserRequestDetailVO>() {
                    @Override
                    public void onResponse(UserRequestDetailVO userRequestVO) {
                        LogUtil.i(TAG,"回调getRequestDetail onResponse()方法");
                        if (userRequestVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,userRequestVO.getMsg());
                        }else {
                            Intent intent = new Intent(activity, RequestDetailActivity.class);
                            intent.putExtra("userName",userRequestVO.getUserName());
                            intent.putExtra("userPhone",userRequestVO.getUserPhone());
                            intent.putExtra("place","From "+userRequestVO.getPlace()+"\nTo "+userRequestVO.getDestination());
                            intent.putExtra("description",userRequestVO.getDescription());
                            intent.putExtra("time",userRequestVO.getTime());
                            intent.putExtra("completeMsg",userRequestVO.getCompleteMsg());
                            intent.putExtra("picurl",userRequestVO.getPicurl());
                            intent.putExtra("gdIdStart",gdIdStart);
                            intent.putExtra("activityName","MainActivity");
                            activity.startActivity(intent);
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 获取用户所有请求
     * */
    public static void getUserAllRequest(String userPhone, final List<MyRequestDetailItem> list, final MyRequestDetailAdapter adapter){
        Map<String,String> params=new HashMap<>();
        params.put("userPhone",userPhone);
        params.put("count", String.valueOf(SharedPrefUtil.getReqCount()));
        MyGsonRequest<UserAllRequestVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.GET_ALL_REQUEST,
                params,
                UserAllRequestVO.class,
                new Response.Listener<UserAllRequestVO>() {
                    @Override
                    public void onResponse(UserAllRequestVO userAllRequestVO) {
                        LogUtil.i(TAG,"回调getUserAllRequest onResponse()方法");
                        if (userAllRequestVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,userAllRequestVO.getMsg());
                        }else {
                            SharedPrefUtil.saveReqCount(userAllRequestVO.getCount());
                            List<MyUserRequestItemVO>mList = userAllRequestVO.getList();
                            for (MyUserRequestItemVO vo:mList){
                                MyRequestDetailItem item = new MyRequestDetailItem(vo.getPicurl(),vo.getPlace(),vo.getDestination(),
                                        vo.getTime(),vo.getCompleteMsg(),vo.getDescription(),vo.getRequestId(),vo.getDriverName(),vo.getDriverPhone());
                                LogUtil.i(TAG,item.toString());
                                list.add(item);
                            }
                            adapter.notifyDataSetChanged();
                            ToastUtil.showToast(context,userAllRequestVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 获取用户所有接单
     * */
    public static void getUserAllOrder(String userPhone, final List<MyRequestDetailItem> list, final MyRequestDetailAdapter adapter, final ProgressDialog dialog){
        Map<String,String> params=new HashMap<>();
        params.put("userPhone",userPhone);
        params.put("count", String.valueOf(SharedPrefUtil.getOrderCount()));
        MyGsonRequest<UserAllOrderVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.GET_ALL_ORDER,
                params,
                UserAllOrderVO.class,
                new Response.Listener<UserAllOrderVO>() {
                    @Override
                    public void onResponse(UserAllOrderVO userAllOrderVO) {
                        LogUtil.i(TAG,"获取用户所有接单 onResponse()方法,返回参数size="+userAllOrderVO.getCount());
                        LogUtil.i(TAG,"接单具体信息:"+userAllOrderVO.getList().toString());

                        if (userAllOrderVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,userAllOrderVO.getMsg());
                        }else {
                            SharedPrefUtil.saveReqCount(userAllOrderVO.getCount());
                            List<OrderItemVO>mList = userAllOrderVO.getList();
                            for (OrderItemVO vo:mList){
                                MyRequestDetailItem item = new MyRequestDetailItem(vo.getPicurl(),vo.getPlace(),vo.getDestination(),
                                        vo.getTime(),vo.getCompleteMsg(),vo.getDescription(),vo.getRequestId(),vo.getCustomerName(),vo.getCustomerPhone());
                                list.add(item);
                            }
                            adapter.notifyDataSetChanged();
                            dialog.dismiss();
                            ToastUtil.showToast(context,userAllOrderVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 用户删除请求
     * */
    public static void deleteUserRequest(int requestId,final int deletePositon,final Activity activity){
        Map<String,String> params=new HashMap<String, String>();
        params.put("requestId",String.valueOf(requestId));
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.DELETE_USER_REQUEST,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        LogUtil.i(TAG,"回调deleteUserRequest onResponse()方法");
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }else {
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                            MyApplication.setDeletePosition(deletePositon);
                            activity.finish();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 用户接单
     * */
    public static void acceptRequest(String userPhone,String gdIdStart,final Activity activity){
        Map<String,String> params=new HashMap<>();
        params.put("userPhone",userPhone);
        params.put("gdIdStart",gdIdStart);
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.ACCEPT_REQUEST,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        LogUtil.i(TAG,"回调getRequestDetail onResponse()方法");
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }else {
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                            activity.finish();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 用户投诉
     * */
    public static void userReport(String content,String userPhone,final ProgressDialog dialog){
        Map<String,String> params=new HashMap<>();
        params.put("userPhone",userPhone);
        params.put("content",content);
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.USER_REPORT,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        LogUtil.i(TAG,"回调用户投诉 onResponse()方法");
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }else {
                            dialog.dismiss();
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 车主完成请求
     * */
    public static void driverCompleteOrder(String center,String userPhone,int requestId,final ProgressDialog dialog){
        Map<String,String> params=new HashMap<>();
        params.put("userPhone",userPhone);
        params.put("center",center);
        params.put("requestId",String.valueOf(requestId));
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.DRIVER_COMPLETE_ORDER,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        LogUtil.i(TAG,"回调车主完成订单 onResponse()方法");
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                            dialog.dismiss();
                        }else {
                            dialog.dismiss();
                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 用户确认订单已完成
     * */
    public static void userConfirmOrder(int requestId,final ProgressDialog dialog){
        Map<String,String> params=new HashMap<>();
        params.put("requestId",String.valueOf(requestId));
        MyGsonRequest<UserVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.USER_CONFIRM_ORDER,
                params,
                UserVO.class,
                new Response.Listener<UserVO>() {
                    @Override
                    public void onResponse(UserVO userVO) {
                        LogUtil.i(TAG,"回调用户确认订单完成 onResponse()方法");
                        if (userVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,userVO.getMsg());
                            dialog.dismiss();
                        }else {
                            dialog.dismiss();
                            ToastUtil.showToast(context,userVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 用户查看积分
     * */
    public static void checkUserPoint(String userPhone, final TextView textView){
        Map<String,String> params=new HashMap<>();
        params.put("userPhone",userPhone);
        MyGsonRequest<UserVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.CHECK_USER_POINT,
                params,
                UserVO.class,
                new Response.Listener<UserVO>() {
                    @Override
                    public void onResponse(UserVO userVO) {
                        LogUtil.i(TAG,"回调用户确认订单完成 onResponse()方法");
                        if (userVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,userVO.getMsg());
                        }else {
                            textView.setText("当前积分 "+userVO.getUserPoint()+" 分");
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    /**
     * 用户查看周围请求列表
     * */
    public static void showAroundOrderList(final ProgressDialog dialog, String userPhone,
                                           String center, String radius, final List<HashMap<String, String>> listString, final SimpleAdapter adapter){
        Map<String,String> params=new HashMap<>();
        params.put("center",center);
        params.put("radius",radius);
        params.put("userPhone",userPhone);
        MyGsonRequest<AroundSearchVO>myGsonRequest = new MyGsonRequest<>(
                Request.Method.POST,
                NetAccessUrl.AROUND_SEARCH,
                params,
                AroundSearchVO.class,
                new Response.Listener<AroundSearchVO>() {
                    @Override
                    public void onResponse(AroundSearchVO aroundSearchVO) {
                        LogUtil.i(TAG,"showAroundOrderList onResponse()方法");
                        if (aroundSearchVO.getResultCode()==AroundSearchVO.RESULT_CODE_FAIL){
                            ToastUtil.showToast(context,aroundSearchVO.getMsg());
                            dialog.dismiss();
                        }else {
                            for (AroundSearchInfoVO aroundSearchInfoVO:aroundSearchVO.getAroundSearchInfoVOS()){
                                LogUtil.i(TAG,aroundSearchInfoVO.toString());
                                HashMap<String,String>hashMap = new HashMap<>();
                                hashMap.put("startPlace",aroundSearchInfoVO.getPlace());
                                hashMap.put("stopPlace",aroundSearchInfoVO.getDestination());
                                hashMap.put("gdIdStart",aroundSearchInfoVO.get_id());
                                listString.add(hashMap);
                            }
                            adapter.notifyDataSetChanged();
                            dialog.dismiss();
                            ToastUtil.showToast(context,aroundSearchVO.getMsg());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }
    public static void getNotifyFlag(String userPhone){
        Map<String,String> params=new HashMap<String, String>();
        params.put("userPhone",userPhone);
        MyGsonRequest<BaseResultVO>myGsonRequest = new MyGsonRequest<BaseResultVO>(
                Request.Method.POST,
                NetAccessUrl.GET_NOTIFY_FLAG,
                params,
                BaseResultVO.class,
                new Response.Listener<BaseResultVO>() {
                    @Override
                    public void onResponse(BaseResultVO baseResultVO) {
                        LogUtil.i(TAG,"回调getNotifyFlag()方法");
                        if (baseResultVO.getResultCode()==BaseResultVO.RESULT_CODE_FAIL){
//                            ToastUtil.showToast(context,baseResultVO.getMsg());
                        }else {
                            Intent i = new Intent(MyApplication.getContext(), MyRequestActivity.class);
                            NotificationUtil.getNotification(i,MyApplication.getContext());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e(TAG,volleyError.toString());
                    }
                });
        requestQueue.add(myGsonRequest);
    }

}
